#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <QTimer>
#include "commsignalslot.h"

#include <functional>
#include <mutex>

class TcpClient : public QObject
{
    Q_OBJECT
public:
    TcpClient(QObject *parent = nullptr);

    static TcpClient* Intance();

    void tcpClientStop();
    bool isTcpConnect();

signals:
    void tcpSignalLog(CommSignalSlot::logType, const QString&, const QString&);

public slots:
    void tcpSlotStart(const QString&, quint16);
    void sendData(const QByteArray &data);

private slots:
    void connected();
    void disconnected();
    void readData();

    void SlotTimer();

private:
    bool isConnect;
    QTcpSocket *tcpSocket;
    QTimer *timer;
};

#endif // TCPCLIENT_H
